Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Jira API requests between JSM/JS/Jira to correct permission map/resolver #62

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

dxu2-atlassian
Copy link
Contributor

@dxu2-atlassian dxu2-atlassian commented Dec 23, 2024

JSM/JS/Jira all seem to be bundled within requestJira inside Forge, this will separate those requests and route them to the proper permission map/resolver for classification.

@dxu2-atlassian dxu2-atlassian force-pushed the feat/EAS-2549 branch 6 times, most recently from fecbc4d to 7de9e27 Compare January 3, 2025 20:53
@dxu2-atlassian dxu2-atlassian marked this pull request as ready for review January 3, 2025 21:16
}
_ => {
warn!("First parameter to requestJira() is invalid");
IntrinsicName::RequestJira // TODO: how should we handle this edge case?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to produce the least amount of false positives, then we should conservatively assume it can use any of Jira APIs if we can't statically determine which one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, do you mean create another IntrinsicName enum like IntrinsicName::RequestJiraAny and then have that correspond to a combined resolver/regex map of JS + Jira + JSM here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that works.

@dxu2-atlassian dxu2-atlassian marked this pull request as draft January 7, 2025 21:33
@dxu2-atlassian dxu2-atlassian marked this pull request as ready for review January 8, 2025 18:54
url if url.starts_with("/rest/servicedeskapi/") => {
Some(IntrinsicName::RequestJiraServiceManagement)
}
url if url.starts_with("/rest/agile/") => Some(IntrinsicName::RequestJiraSoftware),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other Jira Software URL patterns like /rest/devinfo and /rest/builds. See the API docs for others.

IntrinsicName::RequestJiraAny
})
} else {
panic!("No url identifiable to classify requestJira() type");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just fallback to RequestJiraAny instead of panicing.

panic!("No url identifiable to classify requestJira() type");
}
}
_ => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also handle the case for when first_arg is a string literal: https://rustdoc.swc.rs/swc_ecma_ast/enum.Expr.html#variant.Lit.

@dxu2-atlassian dxu2-atlassian force-pushed the feat/EAS-2549 branch 2 times, most recently from 6d2bfc2 to baa65b2 Compare January 22, 2025 17:51
@@ -1112,7 +1119,7 @@ impl<'cx> Dataflow<'cx> for PermissionDataflow {
interp.bitbucket_permission_resolver,
interp.bitbucket_regex_map,
),
_ => unreachable!("Invalid intrinsic function type"),
_ => (&PermissionHashMap::new(), &HashMap::<String, Regex>::new()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the rest of the cases to make this match exhaustive? So we don't forget to update this in the event that we add other services/intrinsics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a list of the rest of all the possible cases for this?

Is it just every possible case from here: https://developer.atlassian.com/platform/forge/apis-reference/fetch-api-product.requestbitbucket/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean just filling out the match arm with the rest of the variants of IntrinsicName. There should be a rust_analyzer code action for doing this.

Also, you should install rust-analyzer if you haven't already.

@jwong101
Copy link
Contributor

LGTM once the match is exhaustive.

@dxu2-atlassian dxu2-atlassian force-pushed the feat/EAS-2549 branch 2 times, most recently from adb41bc to d875900 Compare January 23, 2025 20:40
@jwong101 jwong101 merged commit bed13f1 into atlassian-labs:main Jan 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants